<?php

namespace app\shadmin\controller;


use think\Db;
use think\Request;



class Market extends \think\Controller
{
    public function _initialize()
    {
        // parent::_initialize();
        if (!session('?aid')) {

            $this->redirect('shadmin/login/index');


        }
         
        
         
         if(session('status')!=="市场部" && session('status')!="管理员"){

           echo "<Script>alert('暂无权限')</script>";
           die;

          // $this->redirect('shadmin/login/out');
         

        }

    }


    public function index(){
          
     

   


       $list=Db::table('news_cate')->where("Level",1)->select();
       $this->assign('catelist',$list);

        return view();
    }







    public function main(){


       


 $this->redirect('ztlist');



      
        return view();


    }



    public function wx()
    {

        $script = &  load_wechat('Script');
        $qm = $script->getJsSign('http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]);

        dump($script);




    }





 

    public function ztlist(){

         $list = Db::table('zhanhui_shangjia')->order('id desc')->select();

         $this->assign('list',$list);

        return view();

    }


    public function zt(){
       
        if(IS_AJAX()){
         
          $s = input('param.');
          $s['addtime']=date('Y-m-d H:i:s');
          $s['addname']=session('name');
         
         if($s['tid']){
                                
            Db::table('zhanhui_shangjia')->where(['id'=>$s['tid']])->strict(false)->update($s);


         }else{

           Db::table('zhanhui_shangjia')->strict(false)->insert($s);

         }

       

        $json['code']=200;
        return json($json);

        }else{

         $list=Db::table('zhanhui_chengshi')->select();;
         $this->assign('list',$list);


          if(input('id')){
           
          $t=Db::table('zhanhui_shangjia')->find(input('id'));
         $this->assign('t',$t);
         }
        
         return view();

        }


       

    }




     public function splist(){

         $list = Db::table('zhanhui_dbcp')->order('id desc')->select();

         $this->assign('list',$list);

        return view();

    }


    public function sp(){
       $s = input('param.');
       
         if(IS_AJAX()){
         
         
          $s['addtime']=date('Y-m-d H:i:s');
          $s['addname']=session('name');
         
         if($s['tid']){
                                
            Db::table('zhanhui_dbcp')->where(['id'=>$s['tid']])->strict(false)->update($s);


         }else{
     
           Db::table('zhanhui_dbcp')->strict(false)->insert($s);

         }

       

        $json['code']=200;
        return json($json);

        }else{

         $list=Db::table('zhanhui_shangjia')->select();;
         $this->assign('list',$list);
       

        if($s['id']){
         $t=Db::table('zhanhui_dbcp')->find(input('id'));
         $this->assign('t',$t);
         }

         return view();

        }


       

    }




  public function jdlist(){

         $list = Db::table('tour_product')->order('id desc')->select();

         $this->assign('list',$list);

        return view();

    }


    public function jd(){
       
         if(IS_AJAX()){
         
          $s = input('param.');
          $s['addtime']=date('Y-m-d H:i:s');
          $s['addname']=session('name');
         
         if($s['tid']){
                                
            Db::table('tour_product')->where(['id'=>$s['tid']])->strict(false)->update($s);


         }else{

           Db::table('tour_product')->strict(false)->insert($s);

         }

       

        $json['code']=200;
        return json($json);

        }else{

         $list=Db::table('tour_cate')->select();;
         $this->assign('list',$list);
         if(input('id')){
           
            $t=Db::table('tour_product')->find(input('id'));
         $this->assign('t',$t);

         }
        
         return view();

        }


       

    }


  





   public function ly(){


   }




   public function lylist(){





   }







}